package com.kang.manager.controller;

import com.kang.common.R;
import com.kang.manager.service.IItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/manager/item")
@Slf4j
public class ItemController {

	@Autowired
	private IItemService itemService;

	/**
	 * 获取商品列表
	 *
	 * @return 包含商品列表的响应对象
	 */
	@GetMapping("/list")
	public R list() {
		log.info("Fetching item list.");
		try {
			return R.ok().put("list", itemService.list());
		} catch (Exception e) {
			log.error("Error fetching item list", e);
			return R.error("Failed to fetch item list.");
		}
	}
}
